<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title>后台登录</title>
        <link rel="stylesheet" type="text/css" href="/Admin/layuiadmin/layui/css/layui.css" />
        <link rel="stylesheet" type="text/css" href="/Admin/layuiadmin/css/login.css" />
    </head>

    <body>
        <div class="m-login-bg">
            <div class="m-login">
                <h3>后台管理系统</h3>
                <div class="m-login-warp">
                    <form class="layui-form" method="POST" action="{{route('login.post')}}">
                        {{ csrf_field() }}
                        <div class="layui-form-item">
                            <input type="text" name="username" value="{{ old('username') }}" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <input type="text" name="captcha" required lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <img class="verifyImg"  src="{{ captcha_src('flat') }}" onclick="this.src='/captcha/flat?'+Math.random()" title="点击图片重新获取验证码">
                            </div>
                        </div>


                        <div class="layui-form-item m-login-btn">
                            <div class="layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="login">登录</button>
                            </div>
                            <div class="layui-inline">
                                <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- <p class="copyright">Copyright 2015-2016</p> -->
            </div>
        </div>
        <script src="/Admin/layuiadmin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
        <script src="/Admin/js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="/admin/assets/layer/layer.js"></script>
        <script>
        $(function(){
            if(window.parent!=window){
                //console.log('这事子级页面');
                window.parent.location.reload(true);
            }
        })


            layui.use(['form', 'layedit', 'laydate'], function() {
                var form = layui.form,
                    layer = layui.layer;
                @if(session('error'))
                layer.msg('{{session('error')}}');
                @endif
                @if(count($errors)>0)
                @foreach($errors->all() as $error)
                layer.msg("{{$error}}",{icon:5});
                @break
                @endforeach
                @endif
                //信息提示
                @if(session('status'))
                layer.msg("{{session('status')}}",{icon:6});
                @endif
                //自定义验证规则
                form.verify({
                    username: function(value) {
                        if(value.length < 5) {
                            return '标题至少得5个字符啊';
                        }
                    },
                    password: [/(.+){6,12}$/, '密码必须6到12位'],
                    captcha: [/(.+){6}$/, '验证码必须是6位'],

                });
            });
        </script>
    </body>

</html>